#ifndef __GSM__MODEL_H__
#define __GSM__MODEL_H__

#include <glib-object.h>
#include "gsm-watcher.h"

G_BEGIN_DECLS

#define GSM_TYPE_MODEL				(gsm_model_get_type ())
#define GSM_MODEL(obj)				(G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_MODEL, GsmModel))
#define GSM_MODEL_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_MODEL, GsmModelClass))
#define GSM_IS_MODEL(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_MODEL))
#define GSM_IS_MODEL_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_MODEL))
#define GSM_MODEL_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_MODEL, GsmModelClass))

typedef struct _GsmModel GsmModel;
typedef struct _GsmModelClass GsmModelClass;

struct _GsmModel {
	GObject parent_object;
	
	GHashTable *friends;
	GSList *watchers;
	GSList *watcher_iter;
	gint sid;
	glong rate;
	gboolean pause;
};

struct _GsmModelClass {
	GObjectClass parent_class;
	
	void (*watcher_add)		(GsmModel *model, GsmWatcher *watcher, gpointer user_data);
	void (*watcher_update)	(GsmModel *model, GsmWatcher *watcher, gpointer user_data);
	void (*watcher_remove)	(GsmModel *model, GsmWatcher *watcher, gpointer user_data);
	void (*watcher_error)	(GsmModel *model, GsmWatcher *watcher, GError *error, gpointer user_data);
	void (*friend_add)		(GsmModel *model, const gchar *name, gboolean notify, gpointer user_data);
	void (*friend_update)	(GsmModel *model, const gchar *name, gchar *address, gboolean notify, gpointer user_data);
	void (*friend_remove)	(GsmModel *model, const gchar *name, gpointer user_data);
	void (*friend_online)	(GsmModel *model, const gchar *name, GsmWatcher *watcher, gpointer user_data);
};

GType gsm_view_get_type (void) G_GNUC_CONST;
GsmModel *gsm_model_new ();

GsmWatcher *gsm_model_add_server	(GsmModel *model, const gchar *address);
void gsm_model_remove_server		(GsmModel *model, GsmWatcher *watcher);
void gsm_model_load_servers			(GsmModel *model);

void gsm_model_set_update_rate	(GsmModel *model, glong rate);
glong gsm_model_get_update_rate	(GsmModel *model);
void gsm_model_set_pause		(GsmModel *model, gboolean pause);
gboolean gsm_model_get_pause	(GsmModel *model);

GsmWatcher *gsm_model_find_by_address (GsmModel *model, const gchar *address);

void gsm_model_add_friend		(GsmModel *model, const gchar *name, gboolean notify);
void gsm_model_update_friend	(GsmModel *model, const gchar *name, gboolean notify);
void gsm_model_remove_friend	(GsmModel *model, const gchar *name);
void gsm_model_load_friends		(GsmModel *model);
gboolean gsm_model_find_friend	(GsmModel *model, const gchar *name, gboolean *notify);

G_END_DECLS

#endif